{php include wl_template('common/header');}
<ul class="nav nav-tabs" id="myTab">
	<li class="active"><a href="#tab_basic">充值设置</a></li>
</ul>
<div class="app-content">
<div class="app-form">
	<form action="" method="post" class="form-horizontal form form-validate" id="setting-form">
		<div class="panel panel-default">
			<div class="panel-heading">充值设置</div>
			<div class="tab-content">
				<div class="tab-pane active" id="tab_basic">
					<div class="form-group">
						<label class="col-sm-2 control-label">余额充值</label>
						<div class="col-sm-9">
							<label class="radio-inline">
								<input type="radio" onclick="$('#set_list').show()" id="inlineRadio1" name="recharge[status]" value="1" {if intval($settings['status']) == 1}checked="checked"{/if}>开启
							</label>
							<label class="radio-inline">
								<input type="radio" onclick="$('#set_list').hide()" id="inlineRadio2" name="recharge[status]" value="0" {if intval($settings['status']) == 0 || empty($settings['status'])}checked="checked"{/if}>关闭
							</label>
						</div>
					</div>
					<div id="set_list" {if  intval($settings['status']) != 1}style="display:none;"{/if}>
						<div class="form-group">
							<label class="col-sm-2 control-label">自定义充值金额</label>
							<div class="col-sm-9">
								<label class="radio-inline">
									<input type="radio" name="recharge[diymoney]" value="0" {if intval($settings['diymoney']) == 0 || empty($settings['diymoney'])}checked="checked"{/if}>开启
								</label>
								<label class="radio-inline">
									<input type="radio" name="recharge[diymoney]" value="1" {if intval($settings['diymoney']) == 1}checked="checked"{/if}>关闭
								</label>
							</div>
						</div>
						{loop $array $li}
							<div class="form-group tag">
								<label class="col-sm-2 control-label">充值优惠</label>
								<div class="col-sm-9">
									<div class="input-group">
										<span class="input-group-addon">满</span>
										<input type="text" class="form-control" name="recharge[kilometre][]" value="{php echo sprintf('%.2f',$li['kilometre'])}">
										<span class="input-group-addon">送</span>
										<input type="text" class="form-control" name="recharge[kilmoney][]"  value="{php echo sprintf('%.2f',$li['kilmoney'])}">
										<span class="input-group-addon">元</span>
										<div class="col-sm-1">
										<span class="btn btn-default btn-add-type2 delrule" >
												<i class="fa fa-remove delrule"></i>
										</span>
										</div>
									</div>
								</div>
							</div>
						{/loop}
						<div id="newrule"></div>
						<div class="form-group formone">
							<label class="col-sm-2 control-label"></label>
							<div class="col-sm-9">
								<div class="input-group">
									<a class=" btn btn-default btn-add-type2" href="javascript:;" id="addrule">
										<i class="fa fa-plus" title=""></i>增加一条优惠
									</a>
								</div>
							</div>
						</div>
						{if $isAuth}
						<div class="form-group">
							<label class="col-sm-2 control-label">乐豆提示1</label>
							<div class="col-sm-9">
								<input type="text" name="recharge[dhtip1]" placeholder="1乐豆抵用1元" class="form-control" value="{$settings['dhtip1']}" />
								<span class="help-block">商品详情页面提示。</span>
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-2 control-label">乐豆提示2</label>
							<div class="col-sm-9">
								<input type="text" name="recharge[dhtip2]" placeholder="中国移动/中国银行积分可兑换乐豆" class="form-control" value="{$settings['dhtip2']}" />
								<span class="help-block">商品详情页面和支付页面支付提示。</span>
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-2 control-label">兑换乐豆链接</label>
							<div class="col-sm-9">
								<input type="text" name="recharge[dhurl]" class="form-control" value="{$settings['dhurl']}" />
								<span class="help-block">显示在商品详情和支付页面的兑换乐豆链接。</span>
							</div>
						</div>
						{/if}
					</div>
				</div>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label"></label>
			<div class="col-sm-9">
				<input type="submit" name="submit" value="提交" class="btn btn-primary min-width" />
				<input type="hidden" name="token" value="{$_W['token']}" />
			</div>
		</div>
	</form>
</div>
</div>
<script>
$(function () {
		window.optionchanged = false;
		$('#myTab a').click(function (e) {
			e.preventDefault();//阻止a链接的跳转行为
			$(this).tab('show');//显示当前选中的链接及关联的content
		})
	});
	
	$('#addrule').click(function(){
		var html='';
			html+=
			'<div class="form-group tag">\n' +
                '\t\t\t\t\t\t<label class="col-sm-2 control-label">充值优惠</label>\n' +
                '\t\t\t\t\t\t<div class="col-sm-9">\n' +
                '\t\t\t\t\t\t\t<div class="input-group">\n' +
                '\t\t\t\t\t\t\t\t<span class="input-group-addon">满</span>\n' +
                '\t\t\t\t\t\t\t\t<input type="text" class="form-control" name="recharge[kilometre][]" value="">\n' +
                '\t\t\t\t\t\t\t\t<span class="input-group-addon">送</span>\n' +
                '\t\t\t\t\t\t\t\t<input type="text" class="form-control" name="recharge[kilmoney][]"  value="">\n' +
                '\t\t\t\t\t\t\t\t<span class="input-group-addon">元</span>\n' +
                '\t\t\t\t\t\t\t\t<div class="col-sm-1">\n' +
                '\t\t\t\t\t\t\t\t<span class="btn btn-default btn-add-type2 delrule" >\n' +
                '\t\t\t\t\t\t\t\t\t\t<i class="fa fa-remove delrule"></i>\n' +
                '\t\t\t\t\t\t\t\t</span>\n' +
                '\t\t\t\t\t\t\t\t</div>\n' +
                '\t\t\t\t\t\t\t</div>\n' +
                '\t\t\t\t\t\t</div>\n' +
                '\t\t\t\t\t</div>';
		$('#newrule').append(html);	
	})
	$(document).on('click', '.delrule', function() {
		$(this).closest('.tag').remove();
	});
</script>
{php include wl_template('common/footer');}